<%@page import="java.util.Calendar"%>
<%@page import="model.CategoryModel"%>
<%@page import="model.NewsModel"%>
<%@page import="model.SubCategoryModel"%>
<%@page import="entity.SubCategory"%>
<%@page import="entity.Category"%>
<%@page import="entity.News"%>
<%@page import="java.util.List"%>
<%@page import="util.ResourceHelper"%>
<%
	request.setCharacterEncoding("UTF-8");
	CategoryModel cateModel = new CategoryModel();
	NewsModel newsModel = new NewsModel();
	String cate = "index";		
	Object objCal = request.getAttribute("date");
	boolean ok = false;
	Calendar cal = null;	
	try{
		cal =  (Calendar) objCal;			
		ok = true;
	}catch(Exception e){
		
	}
	if(ok&&cal!=null){
	String keywords = ResourceHelper.getByAlias("tin-theo-ngay") + " : " + cal.get(Calendar.DATE) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.YEAR);
	String title = ResourceHelper.getByAlias("tin-theo-ngay") + " : " + cal.get(Calendar.DATE) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.YEAR) + " - " + ResourceHelper.getByAlias("luu-tru-tin");
	String description = ResourceHelper.getByAlias("description");
%>
<jsp:include page="/layout/header.jsp">	
	<jsp:param name="title" value="<%=title %>"/>
	<jsp:param name="cate" value="<%=cate %>"/>
	<jsp:param name="keywords" value="<%=keywords %>"/>
	<jsp:param name="description" value="<%=description %>"/>
</jsp:include>
            <div id="content">
                <div id="leftsidecontent">
                    <div class="box-wrap">
                        <div class="box-categories">
                            <%                            	                               
                                for (Category item : cateModel.all()) {
                                    List<News> list = newsModel.findByDay(item.getAlias(), cal);                                    
                                    if (list.size() > 0) {
                            %>                                   
                            <div class="box-item">
                                <div class="box-item_inner" style="height: 260px">

                                    <h3 class="heading"><a href="/<%=item.getAlias() %>"><%= item.getTitle()%></a></h3>
                                    <ul>
                                        <%
                                            for (News news : list) {
                                        %>
                                        <li><a href="/<%=news.getAlias()%>.html"><%=news.getTitle()%></a></li>
                                        <%
                                            }
                                        %>                                                                        
                                    </ul>
                                    <a class="readmore" href="/<%= item.getAlias()%>">Xem them</a>
                                </div>
                            </div>
                            <%
                                    }
                                }

                            %>                                                        
                            <div class="clearbreak"></div>                        
                        </div>                       
                    </div>
                </div>
                <div id="rightsidecontent">
                    <div class="box-wrap">
                        <jsp:include page="/element/search.jsp">	
                        	<jsp:param name="cate" value="<%=cate %>"/>	
						</jsp:include>
                        <jsp:include page="/element/latest_news.jsp">	
                        	<jsp:param name="cate" value="<%=cate %>"/>	
						</jsp:include>
                        <jsp:include page="/element/date_picker.jsp">
                        	<jsp:param name="cate" value="<%=cate%>"/>		
						</jsp:include>
                        <div class="clearbreak"></div>
                    </div>
                </div>
                <div class="clearbreak"></div>
            </div>
<jsp:include page="/layout/footer.jsp">	
	<jsp:param name="cate" value="<%=cate%>"/>	
</jsp:include>
<%
}else{
	response.sendRedirect("/home");
}
%>